<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img class="outline-parent-bg" :src="publicUrls + 'free/style6/AuxiliaryoutlineStyle4Bg.webp'" alt="" />
    <div class="outline border-hover-style">
      <t-popup
        class="placement align"
        content="音频"
        placement="bottom"
        attach="#auxiliary-item"
        destroyOnClose
        :showArrow="true"
        :trigger="store.isMobileType ? 'click' : 'hover'"
      >
        <img
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
          :src="publicUrls + 'free/style6/AuxiliaryoutlineStyle2Audio.webp'"
        />
      </t-popup>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div
        class="outline-content"
        :style="!props.info.subTitle && !props.info.remarks && !props.info.value && { justifyContent: 'center' }"
      >
        <div class="outline-title">
          {{ props.info.text }}
        </div>
        <p class="outline-subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</p>
        <div class="content-item" v-if="props.info.value || (props.info.video && props.info.video.url)">
          <div class="medium">
            <img
              v-if="props.info.value && !(props.info.video && props.info.video.url)"
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
              alt=""
            />
            <videoview @click="audioplay(false)" :info="props.info"></videoview>
          </div>
        </div>

        <TextMax
          v-if="props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :infoData="props.info"
          :row="props.info.value ? 2 : !props.info.value && props.info.subTitle ? 5 : 7"
        ></TextMax>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free6Style4',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 218px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.outline-parent-bg {
  width: 370px;
  height: 500px;
  margin-top: 10px;
  // margin-right: 10px;
}

.outline {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 20;
  width: 370px;
  height: 500px;
  padding: 90px 16px 111px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.outline-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 256px;
  height: 100%;
  overflow: hidden;
}
.outline-title {
  margin-bottom: 10px;
  width: 161px;
  color: #737d87;
  font-size: 20px;
  line-height: 28px;
  text-align: center;
  font-family: 'SourceHanSerifCN-Bold';
}
.outline-subTitle {
  width: 100%;
  font-family: SourceHanSerifCN;
  font-size: 16px;
  color: #686763;
  line-height: 28px;
  text-align: center;
  margin-bottom: 8px;
}
.content-item {
  width: 100%;
  max-height: 234px;
  flex: 1;
  overflow: hidden;
  background: #ded9d3;
  margin-bottom: 8px;
  &:hover .medium {
    transform: scale(1.2);
  }
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  transition: all 0.3s ease;
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: #f1efea;
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}

.audio-box {
  width: 40px;
  height: 40px;
  position: absolute;
  bottom: 50px;
  border-radius: 50%;
  box-shadow: 5px 3.333px 3.333px rgba(0, 0, 0, 0.05);
}

::v-deep .van-text-ellipsis {
  color: #686763 !important;
  text-align: justify;
  font-family: 'PingFangSC';
  font-size: 16px;
  line-height: 28px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #737d87 !important;
  font-weight: 800 !important;
}
::v-deep .t-popup__content {
  background: #56677b;
  box-shadow: none;
  padding: 2px 12px;
  line-height: 20px;
  font-size: 13px;
  color: #f1efea;
}
::v-deep .t-popup__arrow::before {
  background: #56677b;
  border: none;
  box-shadow: none !important;
}
</style>
